|
|
|
|
|
|
|
instantly. It then took about 8 seconds to examine all of the picture's 349,920 pixels and produce the result. |
|
|
|
|
|
|
|
|
All image processing applications have the same problem. Examining all of the pixels in a large image takes a long time, even if the operation performed on each pixel is fast. |
|
|
|
|
|
|
|
|
To complement an image, you simply subtract each pixel's red, green, and blue component values from the largest possible value of 255. For example, the color orange has red, green, and blue components 255, 127, and 0, respectively. The complement of orange has red component 255255 = 0, green component 255127 = 128, and blue component 2550 = 255. This color is sky blue. |
|
|
|
|
|
|
|
|
Example program Complem, shown in Figure 6.2, uses this technique to display the complement of an image. The figure in this book is grayscale, but the program produces a colored complement image on the computer. |
|
|
|
|
|
|
|
|
The only significant differences between this program and program MakeGray are in the following statements that set a new pixel's color component values. |
|
|
|
 |
|
|
|
|
With pixels(X, Y)
.rgbRed = 255 - .rgbRed
.rgbGreen = 255 - .rgbGreen
.rgbBlue = 255 - .rgbBlue
End With |
|
|
|
|
|
|
|
|
Note that 255 (255 value) = 255 255 + value = value. That means the complement of a color's complement is the original color. You can verify this result by loading an image in program Complem and saving the complemented image. Then load the complemented image in program Complem. You will see that the new complement is the same as the original image. |
|
|
|
|
|
|
|
|
Figure 6.2
Program Complem displays the complement of an image. |
|
|
|
|
|